﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Stock
/// </summary>
public class Stock :IBusinessEntity
{
	#region variables
        private string _deliverableID;
        private string _stockPinCode;
        private string _fromStock;
        private string _toStock;
        private string _receivedDate;
        private string _sentDate;
        private bool _status;
    #endregion

    #region constructors
        public Stock()
        {
            _deliverableID = String.Empty;
            _fromStock=String.Empty;
            _toStock=String.Empty;
            _stockPinCode = String.Empty;
            _status = false;
            _receivedDate=String.Empty;
            _sentDate=String.Empty;
        }
        public Stock(string deliverableID, string stockPinCode, string fromStock, string toStock, string receivedDate, string sentDate, bool status)
        {
            _deliverableID = deliverableID;
            _fromStock=fromStock;
            _toStock=toStock;
            _stockPinCode = stockPinCode;
            _status=status;
            _receivedDate=receivedDate;
            _sentDate=sentDate;
            _status=status;
        }
    #endregion

    #region Property
        public string DeliverableID
        {
            get { return _deliverableID; }
            set { _deliverableID = value; }
        }
        public string StockPinCode
        {
            get { return _stockPinCode; }
            set { _stockPinCode = value; }
        }
        public string FromStock
        {
            get { return _fromStock; }
            set { _fromStock = value; }
        }
        public string ToStock
        {
            get { return _toStock; }
            set { _toStock = value; }
        }
        public string ReceivedDate
        {
            get { return _receivedDate; }
            set { _receivedDate = value; }
        }
        public string SentDate
        {
            get { return _sentDate; }
            set { _sentDate = value; }
        }
        public bool Status
        {
            get { return _status; }
            set { _status = value; }
        }
    #endregion

     
    #region Method
        public void Fill(SqlDataReader reader)
        {
                if (DAL.ColumnExists(reader, "DeliverableID"))
                _deliverableID = reader.GetInt32(0).ToString().Trim();
                if (DAL.ColumnExists(reader, "StockPinCode"))
                _stockPinCode = reader.GetString(1);
                if (DAL.ColumnExists(reader, "FromStock") && !reader.IsDBNull(2))
                _fromStock=reader.GetString(2);
                if (DAL.ColumnExists(reader, "ToStock") && !reader.IsDBNull(3))
                _toStock = reader.GetString(3);
                if (DAL.ColumnExists(reader, "ReceivedDate"))
                _receivedDate=reader.GetSqlDateTime(4).Value.ToString("dd/MM/yyyy");
                if (DAL.ColumnExists(reader, "SentDate") && !reader.IsDBNull(5) && !reader.IsDBNull(5))
                {
                    _sentDate = reader.GetSqlDateTime(5).Value.ToString("dd/MM/yyyy");
                }
                if (DAL.ColumnExists(reader, "Status"))
                _status=reader.GetBoolean(6);
        }

    #endregion
}
